<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org" >
<head>
    <meta charset="UTF-8">
    <title>评论区</title>
    <style>
        /* 全局样式 */
        body {
            margin: 0;
            padding: 0;
            font-family: 'Arial', sans-serif;
            background: linear-gradient(-45deg, #ff9a9e, #fad0c4, #fbc2eb, #a6c1ee);
            background-size: 400% 400%;
            animation: gradientBG 15s ease infinite;
            color: #333;
        }

        @keyframes gradientBG {
            0% { background-position: 0% 50%; }
            50% { background-position: 100% 50%; }
            100% { background-position: 0% 50%; }
        }

        .container {
            max-width: 800px;
            margin: 0 auto;
            padding: 20px;
            background: rgba(255, 255, 255, 0.8);
            border-radius: 15px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }

        h1 {
            text-align: center;
            color: #ff6f61;
            font-size: 2.5rem;
            text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
        }

        /* 评论表单样式 */
        .comment-form {
            margin-bottom: 30px;
        }

        .comment-form textarea {
            width: 100%;
            padding: 10px;
            border: 2px solid #ff6f61;
            border-radius: 10px;
            font-size: 1rem;
            resize: vertical;
            transition: border-color 0.3s ease;
        }

        .comment-form textarea:focus {
            border-color: #ff3b2f;
            outline: none;
        }

        .comment-form button {
            display: block;
            margin: 10px auto;
            padding: 10px 20px;
            font-size: 1rem;
            font-weight: bold;
            color: #fff;
            background-color: #ff6f61;
            border: none;
            border-radius: 25px;
            cursor: pointer;
            transition: background-color 0.3s ease, transform 0.3s ease;
        }

        .comment-form button:hover {
            background-color: #ff3b2f;
            transform: translateY(-3px);
        }

        /* 评论列表样式 */
        .comment-list {
            margin-top: 20px;
        }

        .comment-item {
            padding: 15px;
            margin-bottom: 15px;
            background: rgba(255, 255, 255, 0.9);
            border-radius: 10px;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
            transition: transform 0.3s ease, box-shadow 0.3s ease;
        }

        .comment-item:hover {
            transform: translateY(-5px);
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
        }

        .comment-item p {
            margin: 5px 0;
        }

        .comment-item .username {
            font-weight: bold;
            color: #ff6f61;
        }

        .comment-item .timestamp {
            font-size: 0.9rem;
            color: #666;
        }

        /* 分页导航样式 */
        .pagination {
            margin-top: 30px;
            text-align: center;
        }

        .pagination a {
            display: inline-block;
            margin: 0 10px;
            padding: 10px 20px;
            font-size: 1rem;
            font-weight: bold;
            color: #fff;
            background-color: #ff6f61;
            border: none;
            border-radius: 25px;
            text-decoration: none;
            transition: background-color 0.3s ease, transform 0.3s ease;
        }

        .pagination a:hover {
            background-color: #ff3b2f;
            transform: translateY(-3px);
        }

        .pagination span {
            font-size: 1.2rem;
            color: #ff6f61;
        }
        /* 菜单栏 */
        #menu-bar {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 60px;
            background-color: rgba(255, 255, 255, 0.9);
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
            display: flex;
            align-items: center;
            justify-content: space-between;
            z-index: 100;
            padding: 0 20px;
            padding-right: calc(20px + 17px); /* 右侧留出滚动条的空间 */
        }

        #menu-bar .logo {
            font-size: 1.5rem;
            font-weight: bold;
            color: #ff6f61;
        }

        #menu-bar .user-info {
            display: flex;
            align-items: center;
            cursor: pointer;
        }

        #menu-bar .user-info img {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            margin-right: 10px;
        }

        #menu-bar .user-info span {
            font-size: 1rem;
            color: #333;
        }
        /* 返回动漫主页按钮样式 */
        .back-to-anime-btn {
            position: fixed;
            bottom: 40px; /* 距离底部 40px */
            right: 40px; /* 距离右侧 40px */
            padding: 12px 24px;
            font-size: 16px;
            font-weight: bold;
            color: #fff;
            background-color: #ff6f61; /* 粉橙色 */
            border: none;
            border-radius: 25px;
            cursor: pointer;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
            transition: background-color 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
            z-index: 1000; /* 确保按钮在最上层 */
        }

        /* 按钮悬停效果 */
        .back-to-anime-btn:hover {
            background-color: #ff3b2f; /* 更深的粉橙色 */
            transform: translateY(-5px);
            box-shadow: 0 6px 8px rgba(0, 0, 0, 0.3);
        }

        /* 按钮点击效果 */
        .back-to-anime-btn:active {
            transform: translateY(0);
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
        }
        /* 返回动漫主页按钮样式 */
        .back-to-anime-btn {
            position: fixed;
            bottom: 40px; /* 距离底部 40px */
            right: 40px; /* 距离右侧 40px */
            padding: 12px 24px;
            font-size: 16px;
            font-weight: bold;
            color: #fff;
            background-color: #ff6f61; /* 粉橙色 */
            border: none;
            border-radius: 25px;
            cursor: pointer;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
            transition: background-color 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
            z-index: 1000; /* 确保按钮在最上层 */
        }

        /* 按钮悬停效果 */
        .back-to-anime-btn:hover {
            background-color: #ff3b2f; /* 更深的粉橙色 */
            transform: translateY(-5px);
            box-shadow: 0 6px 8px rgba(0, 0, 0, 0.3);
        }

        /* 按钮点击效果 */
        .back-to-anime-btn:active {
            transform: translateY(0);
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
        }
    </style>
</head>
<body>
<!-- 菜单栏 -->
<div id="menu-bar">
    <div class="logo">动漫社区</div>

    <a th:href="@{/user/{username}(username=${session.currentUser.username})}" class="user-info">
        <img src="https://via.placeholder.com/40" alt="用户头像">
        <span th:text="${session.currentUser.nickname}">用户名</span>
    </a>

</div>
<div class="container">
    <h1>评论区</h1>

    <!-- 评论表单 -->
    <div class="comment-form">
        <form action="/comments/submit" method="post">
            <textarea name="content" rows="4" placeholder="请输入评论内容"></textarea>
            <br>
            <button type="submit">提交评论</button>
        </form>
    </div>

    <!-- 评论列表 -->
    <div class="comment-list">
        <div th:each="comment : ${comments}" class="comment-item">
            <p class="username" th:text="${comment.username}"></p>
            <p class="timestamp" th:text="${comment.createdAt}"></p>
            <p th:text="${comment.content}"></p>
        </div>
    </div>

    <!-- 分页导航 -->
    <div class="pagination">
        <a th:if="${currentPage > 0}" th:href="@{/comments(page=${currentPage - 1})}">上一页</a>
        <span th:text="'第 ' + (${currentPage + 1}) + ' 页，共 ' + ${totalPages} + ' 页'"></span>
        <a th:if="${currentPage < totalPages - 1}" th:href="@{/comments(page=${currentPage + 1})}">下一页</a>
    </div>
</div>
<button id="back-to-anime" class="back-to-anime-btn">返回动漫主页</button>

<script>
    // 简单的交互效果：评论项点击后放大
    document.querySelectorAll('.comment-item').forEach(item => {
        item.addEventListener('click', () => {
            item.style.transform = 'scale(1.02)';
            setTimeout(() => {
                item.style.transform = 'scale(1)';
            }, 200);
        });
    });
    // 返回动漫主页功能
    document.getElementById('back-to-anime').addEventListener('click', () => {
        window.location.href = '/anime'; // 替换为你的动漫主页 URL
    });
</script>
</body>
</html>